package com.lemon.smartsafetynew.ui.adapter.notice;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lemon.smartsafety.R;
import com.lemon.smartsafetynew.entity.notice.NoticeInfoListVo;
import com.lemon.smartsafetynew.ui.adapter.contact.SortAdapter;

import java.util.List;

/**
 * Created by lzh on 2018/3/16.
 */
public class NoticeInfoLIstAdapter extends BaseAdapter{
    private List<NoticeInfoListVo> datas;
    private Context context;
    private LayoutInflater inflater;
    public NoticeInfoLIstAdapter(List<NoticeInfoListVo> datas, Context context) {
        this.datas = datas;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return datas == null?0:datas.size();
    }

    @Override
    public Object getItem(int i) {
        return datas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if(view == null){
            view = inflater.inflate(R.layout.item_notice,viewGroup,false);
            holder = new ViewHolder(view);
            view.setTag(holder);
        }else{
            holder = (ViewHolder) view.getTag();
        }
        holder.tv_name.setText(datas.get(i).getName());
        return view;
    }

    public class ViewHolder {
        private TextView tv_name;

        public ViewHolder(View view) {
            tv_name = (TextView) view.findViewById(R.id.company_name_tv);
        }
    }
}
